import java.util.Scanner;

public class Day_14_1_计算日期到天数转换 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            int year = sc.nextInt();
            int month = sc.nextInt();
            int day = sc.nextInt();
            int days = outDay(year, month, day);
            System.out.println(days);
        }
    }

    private static int outDay(int year, int month, int day) {
        int[] days = {31, 28, 31, 30,31, 30, 31, 31, 30, 31, 30, 31};

        if(year %4 == 0 && year % 100 != 0 || year % 400 == 0) {
            days[1] = 29;
        }
        if(year <= 0 || month <= 0 || month > 12 || day <= 0 || day> days[month - 1]) {
            return -1;
        }
        int sum = 0;
        for (int i = 0; i < month - 1; i ++) {
            sum += days[i];
        }
        return sum + day;
    }
}
